#include<stdio.h>
#include<stdlib.h>
typedef struct Slist
{
	int num;
	struct Slist* next;
}Slist;

Slist_insert(Slist** linkp,int new_value)
{
	Slist* current,* newSlist;
	
	while((current=*linkp)!=NULL&&current->num<new_value)
		linkp=&current->next;
	
	newSlist=(Slist*)malloc(sizeof(Slist));
	if(newSlist==NULL)
	{
		printf("malloc error");
		exit(1);
	}
	newSlist->num=new_value;
	
	newSlist->next=current;
	*linkp=newSlist;
}

int main()
{
	Slist* phead,*ps;
	phead=(Slist*)malloc(sizeof(Slist));
	if(phead==NULL)
	{
		printf("malloc error");
		exit(1);
	}
	phead->next=NULL;
	phead->num=1;
	Slist_insert(&phead,3);
	Slist_insert(&phead,4);
	Slist_insert(&phead,2);
	Slist_insert(&phead,-1);
	ps=phead;
	while(ps!=NULL)
	{
		printf("%d ",ps->num);
		ps=ps->next;
	}
	return 0;
}
